{% extends "OspOrderBundle::layout.html.twig" %}

{% block OspOrder_body %}
	<h3>Liste des commandes</h3>


	<ul class="nav nav-pills nav-stacked">
		<table class="table table-striped">
			<thead>
				<tr>
					<th>ID</th>
					<th>Utilisateur</th>
					<th>Produits</th>
					<th>Statut</th>
					<th>Frais de port</th>
					<th>Montant</th>
				</tr>
			</thead>
			
			<tbody>
				{% for order in orders %}
				<tr>
					<td>{{order.id}}</td>
					<td>{{order.utilisateur.nom}}</td>
					<td> {{ order.getProducts() | truncate(30, true, '...') }} </td>
					<td>{{order.status}}</td>
					<td>{{order.getFraisPort() ~ ' €'}}</td>
					<td>{{order.getPrix() ~ ' €'}}</td>
					<td>
						<a href="{{ path('osp_order_update', {'id' : order.id}) }}">
							<img src="{{ asset('img/update.png') }}" alt="Modifier" height="27" width="27" />
						</a>
					</td>
					<td>

						<a href="{{ path('osp_order_delete', {'id' : order.id}) }}" onclick="return confirm('Êtes-vous sûr ?')">
							<img src="{{ asset('img/delete.png') }}" alt="Supprimer" height="27" width="27" />
						</a>
					</td>
				</tr>	
				{% endfor %}
			</tbody>
		</table>

		{%if error%}
		{{error}}
		{%endif%}

		<br/>
		<br/>

<div class="well form-inline">
	<form method="post" {{ form_enctype(form) }}>
		
		<legend>Créer une commande</legend>
		<table class="table table-striped">
			<thead>
				<tr>
					<th>Utilisateur</th>
					<th>Produits</th>
					<th>Statut</th>
				</tr>
			</thead>
			
			<tbody>
				<tr>
					<td>{{ form_widget(form.utilisateur, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.listeProduits, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.status, { 'attr': {'class': 'input-small'} }) }}</td>
				</tr>	
			</tbody>
		</table>
		<input type="submit" class="btn btn-primary" value="Créer Commande" style="margin-left:80%" />
		{{ form_rest(form) }}
	</form>
</div>

{% endblock %}